//
//  collectionViewOfMid.m
//  mintHome
//
//  Created by 朱彦名 on 16/6/23.
//  Copyright © 2016年 朱彦名. All rights reserved.
//

#import "collectionViewOfMid.h"
#import "cellOfColOfMid.h"
#import "secondTableViewController.h"
#import "thirdTableViewController.h"
#import "foutThTableViewController.h"
#import "fiveTableViewController.h"

@interface collectionViewOfMid ()

@end

@implementation collectionViewOfMid

static NSString * const reuseIdentifier = @"Cell";

- (instancetype)init{
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    
    layout.itemSize = CGSizeMake(80, 130);
    
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    
    
    return [super initWithCollectionViewLayout:layout];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Register cell classes
    [self.collectionView registerClass:[cellOfColOfMid class] forCellWithReuseIdentifier:reuseIdentifier];
    

    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark <UICollectionViewDataSource>


//- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
//    return 1;
//}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    cellOfColOfMid *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];

    
    
    BOOL model = [AccountManager sharedInstance].isNight;
    if (model == YES) {
        cell.backgroundColor = [UIColor silverColor];
        self.collectionView.backgroundColor = [UIColor silverColor];
    }else{
    
        cell.backgroundColor = [UIColor whiteColor];
        self.collectionView.backgroundColor = [UIColor whiteColor];
    }
    
    NSArray *arr = @[ @"卧室", @"卫浴", @"厨房", @"客厅"];
    cell.label1.text = arr[indexPath.item];
    cell.label1.textAlignment = 1;
    
    NSArray *arr1 = @[ @"woshi.jpg", @"weiyu.jpg", @"chufang.jpg",@"keting.jpg"];
    cell.imageOfMid.image = [UIImage imageNamed:arr1[indexPath.item]];
    cell.imageOfMid.clipsToBounds = YES;
    
    
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.item == 0) {
        secondTableViewController *second = [[secondTableViewController alloc]init];
        [self.navigationController pushViewController:second animated:YES];
        
    }else if (indexPath.item == 1){
        thirdTableViewController *third = [[thirdTableViewController alloc]init];
        [self.navigationController pushViewController:third animated:YES];
        
    }else if (indexPath.item == 2){
        foutThTableViewController *four = [[foutThTableViewController alloc]init];
        [self.navigationController pushViewController:four animated:YES];
        
    }else{
        fiveTableViewController *five = [[fiveTableViewController alloc]init];
        [self.navigationController pushViewController:five animated:YES];
        
    }

}
- (void)setLightDay{
    NSLog(@"%s",__func__);
    [NightManager setBackgroundColorWithView:self.view];
    [self.collectionView reloadData];
    
}
- (void)setNightDay{
    NSLog(@"%s",__func__);
    [NightManager setBackgroundColorWithView:self.view];
    [self.collectionView reloadData];
    
}


@end
